package acwing.前缀和与差分;


import java.util.Scanner;

/**
 * 最大区间和
 *
 * @author yang
 * @date 2021/12/18
 */
public class 最大区间和 {

    static double dp;
    static double ans;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            int x = sc.nextInt();
            dp = Math.max(x,x + dp);
            ans = Math.max(ans,dp);
        }
        System.out.println(ans);
    }
}
